#region README

/*
 * README
 * 
 * Current Thread User : GUOCOLAND\wangyucai
 * Machine Name : GLCHQWYCWINW7
 * Visual Studio : Microsoft Visual Studio 2010 Ultimate Edition
 * Create Time : 2015-02-11 14:19:24
 * Common Language Runtime : 4.0.30319.18444
 * Minimum .Net Framework Version : 4.0
 * 
 * SourcePro Studio 2015
 * Project Url : https://github.com/SourceproStudio/CodeTemplates
 * Home Page Url : https://github.com/SourceproStudio
 * E-mail Address : MasterDuner@yeah.net or Yucai.Wang-Public@outlook.com
 * QQ : 180261899
 */

#endregion

using System.Windows;
using System.Windows.Controls;

namespace Dearcodes.Examples.Wpf.XamlExtensions
{
    /// <summary>
    /// <para>
    /// 用于设置标签文本。
    /// </para>
    /// <para>
    /// Namespace : <see cref="Dearcodes.Examples.Wpf.XamlExtensions"/>
    /// </para>
    /// <para>
    /// Type : <see cref="LabelTextBinding"/>
    /// </para>
    /// <para>
    /// The minimum .Net Framework version requirements : 4.0
    /// </para>
    /// <para>
    /// Can not inherit from <see cref="LabelTextBinding"/> !
    /// </para>
    /// </summary>
    /// <seealso cref="Dearcodes.Examples.Wpf.XamlExtensions"/>
    /// <remarks>
    /// Can not inherit from <see cref="LabelTextBinding"/> !
    /// </remarks>
    public sealed class LabelTextBinding : DependencyObject
    {
        #region LabelTextBinding Constructors

        /// <summary>
        /// <para>
        /// 用于初始化一个<see cref="LabelTextBinding" />对象实例。
        /// </para>
        /// </summary>
        public LabelTextBinding()
        { }

        #endregion

        #region Generate by VisualStudio 2010 propa command (propa tab * 2)

        public static string GetLabelText(DependencyObject obj)
        {
            return (string)obj.GetValue(LabelTextProperty);
        }

        public static void SetLabelText(DependencyObject obj, string value)
        {
            obj.SetValue(LabelTextProperty, value);
        }

        // Using a DependencyProperty as the backing store for LabelText.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty LabelTextProperty =
            DependencyProperty.RegisterAttached("LabelText", typeof(string), typeof(LabelTextBinding), new UIPropertyMetadata("This is a label", new PropertyChangedCallback(OnLabelTextPropertyChanged)));

        #endregion

        #region OnLabelTextPropertyChanged
        /// <summary>
        /// 回调方法。
        /// </summary>
        /// <param name="d"></param>
        /// <param name="e"></param>
        static private void OnLabelTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Label control = d as Label;
            control.Content = e.NewValue;
        }
        #endregion
    }
}

/*
 * Copyright © 2015 Wang Yucai. All rights reserved.
 */